﻿<UserControl x:Class="Samba.Modules.CashModule.CashView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:ListViewLM="clr-namespace:Samba.Presentation.Common.ListViewLM;assembly=Samba.Presentation.Common"
     xmlns:FlexButton="clr-namespace:FlexButton;assembly=FlexButton" xmlns:VirtualKeyboard="clr-namespace:Samba.Presentation.Common.VirtualKeyboard;assembly=Samba.Presentation.Common"
     xmlns:Common="clr-namespace:Samba.Presentation.Common;assembly=Samba.Presentation.Common"
     mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="800" FontSize="20">
    <Grid>
        <TabControl BorderThickness="0" Grid.Column="0" Padding="0" SelectedIndex="{Binding ActiveView}">
            <TabControl.ItemContainerStyle>
                <Style TargetType="{x:Type TabItem}">
                    <Setter Property="Visibility" Value="Collapsed" />
                </Style>
            </TabControl.ItemContainerStyle>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="9*" />
                    <ColumnDefinition Width="1*" />
                </Grid.ColumnDefinitions>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <Border Grid.Row="1" Background="{StaticResource {x:Static SystemColors.ActiveBorderBrushKey}}">
                    </Border>
                    <Grid Grid.Row="0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>
                        <TextBlock FontWeight="Bold" TextAlignment="Left" Style="{StaticResource BlueHeader}"
                             Text="{LocText Income}">
                        </TextBlock>
                        <ListView BorderThickness="0" Grid.Row="0" Background="{StaticResource {x:Static SystemColors.ControlBrushKey}}"
                             VirtualizingStackPanel.IsVirtualizing="True" IsSynchronizedWithCurrentItem="True"
                             ListViewLM:ListViewLayoutManager.Enabled="True" SelectedItem="{Binding SelectedIncomeTransaction}"
                             ItemsSource="{Binding IncomeTransactions}" ItemContainerStyle="{StaticResource ListViewItemExContainerStyle}">
                            <ListView.View>
                                <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{StaticResource BlueBackground}"
                                     ColumnHeaderTemplate="{StaticResource WrappedHeaderTemplate}">
                                    <GridViewColumn Header="{LocText IncomeTransactions}"
                                         ListViewLM:ProportionalColumn.Width="2">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock TextTrimming="CharacterEllipsis" FontSize="16" Text="{Binding Description}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="" ListViewLM:ProportionalColumn.Width="0.6">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock FontSize="16" Foreground="{Binding TextColor}" Text="{Binding DateString}"
                                                     TextAlignment="Center" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="{LocText Cash}" ListViewLM:ProportionalColumn.Width="0.5">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock FontSize="16" Foreground="{Binding TextColor}" Text="{Binding CashPaymentValue,StringFormat='#,#0.00;-#,#0.00; '}"
                                                     TextAlignment="Right" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="{LocText CreditCard_ab}"
                                         ListViewLM:ProportionalColumn.Width="0.5">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock FontSize="16" Foreground="{Binding TextColor}" Text="{Binding CreditCardPaymentValue,StringFormat='#,#0.00;-#,#0.00; '}"
                                                     TextAlignment="Right" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="{LocText Voucher_ab}"
                                         ListViewLM:ProportionalColumn.Width="0.5">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock FontSize="16" Foreground="{Binding TextColor}" Text="{Binding TicketPaymentValue,StringFormat='#,#0.00;-#,#0.00; '}"
                                                     TextAlignment="Right" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>
                        <ListView Grid.Row="1" Background="{StaticResource {x:Static SystemColors.ControlBrushKey}}"
                             ListViewLM:ListViewLayoutManager.Enabled="True" BorderThickness="0" ItemContainerStyle="{StaticResource ListViewItemExContainerStyle}">
                            <ListView.View>
                                <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{StaticResource SilverBackground}"
                                     ColumnHeaderTemplate="{StaticResource WrappedFooterTemplate}">
                                    <GridViewColumn Header="{LocText Total}"
                                         ListViewLM:ProportionalColumn.Width="2.6" />
                                    <GridViewColumn Header="{Binding CashIncomeTotal}" ListViewLM:ProportionalColumn.Width="0.5" />
                                    <GridViewColumn Header="{Binding CreditCardIncomeTotal}" ListViewLM:ProportionalColumn.Width="0.5" />
                                    <GridViewColumn Header="{Binding TicketIncomeTotal}" ListViewLM:ProportionalColumn.Width="0.5" />
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </Grid>
                    <Grid Grid.Row="2">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>
                        <ListView Grid.Row="0" Background="{StaticResource {x:Static SystemColors.ControlBrushKey}}"
                             VirtualizingStackPanel.IsVirtualizing="True" IsSynchronizedWithCurrentItem="True"
                             ListViewLM:ListViewLayoutManager.Enabled="True" ItemsSource="{Binding ExpenseTransactions}"
                             BorderThickness="0" SelectedItem="{Binding SelectedExpenseTransaction}" ItemContainerStyle="{StaticResource ListViewItemExContainerStyle}">
                            <ListView.View>
                                <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{StaticResource BlueBackground}"
                                     ColumnHeaderTemplate="{StaticResource WrappedHeaderTemplate}">
                                    <GridViewColumn Header="{LocText ExpenseTransactions}"
                                         ListViewLM:ProportionalColumn.Width="2">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock TextTrimming="CharacterEllipsis" FontSize="16" Text="{Binding Description}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="" ListViewLM:ProportionalColumn.Width="0.6">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock FontSize="16" Foreground="{Binding TextColor}" Text="{Binding DateString}"
                                                     TextAlignment="Center" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="{LocText Cash}" ListViewLM:ProportionalColumn.Width="0.5">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock FontSize="16" Foreground="{Binding TextColor}" Text="{Binding CashPaymentValue,StringFormat='#,#0.00;-#,#0.00; '}"
                                                     TextAlignment="Right" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="{LocText CreditCard_ab}"
                                         ListViewLM:ProportionalColumn.Width="0.5">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock FontSize="16" Foreground="{Binding TextColor}" Text="{Binding CreditCardPaymentValue,StringFormat='#,#0.00;-#,#0.00; '}"
                                                     TextAlignment="Right" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="{LocText Voucher_ab}"
                                         ListViewLM:ProportionalColumn.Width="0.5">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock FontSize="16" Foreground="{Binding TextColor}" Text="{Binding TicketPaymentValue,StringFormat='#,#0.00;-#,#0.00; '}"
                                                     TextAlignment="Right" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>
                        <ListView Grid.Row="1" Background="{StaticResource {x:Static SystemColors.ControlBrushKey}}"
                             ListViewLM:ListViewLayoutManager.Enabled="True" BorderThickness="0" ItemContainerStyle="{StaticResource ListViewItemExContainerStyle}">
                            <ListView.View>
                                <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{StaticResource SilverBackground}"
                                     ColumnHeaderTemplate="{StaticResource WrappedFooterTemplate}">
                                    <GridViewColumn Header="{LocText Total}"
                                         ListViewLM:ProportionalColumn.Width="2.6" />
                                    <GridViewColumn Header="{Binding CashExpenseTotal}" ListViewLM:ProportionalColumn.Width="0.5" />
                                    <GridViewColumn Header="{Binding CreditCardExpenseTotal}" ListViewLM:ProportionalColumn.Width="0.5" />
                                    <GridViewColumn Header="{Binding TicketExpenseTotal}" ListViewLM:ProportionalColumn.Width="0.5" />
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </Grid>
                    <ListView Grid.Row="3" Background="{StaticResource {x:Static SystemColors.ControlBrushKey}}"
                         ListViewLM:ListViewLayoutManager.Enabled="True" BorderThickness="0" ItemContainerStyle="{StaticResource ListViewItemExContainerStyle}">
                        <ListView.View>
                            <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{StaticResource BlueBackground}"
                                 ColumnHeaderTemplate="{StaticResource WrappedFooterTemplate}">
                                <GridViewColumn Header="{LocText GrandTotal}"
                                     ListViewLM:ProportionalColumn.Width="2.6" />
                                <GridViewColumn Header="{Binding CashTotal}" ListViewLM:ProportionalColumn.Width="0.5" />
                                <GridViewColumn Header="{Binding CreditCardTotal}" ListViewLM:ProportionalColumn.Width="0.5" />
                                <GridViewColumn Header="{Binding TicketTotal}" ListViewLM:ProportionalColumn.Width="0.5" />
                            </GridView>
                        </ListView.View>
                    </ListView>
                </Grid>
                <StackPanel Background="Silver" Grid.Column="1">
                    <FlexButton:FlexButton Margin="2" Height="60" Command="{Binding ActivateIncomeTransactionRecordCommand }"
                         Content="{Binding ActivateIncomeTransactionRecordCommand.Caption}" />
                    <FlexButton:FlexButton Margin="2" Height="60" Command="{Binding ActivateExpenseTransactionRecordCommand }"
                         Content="{Binding ActivateExpenseTransactionRecordCommand.Caption}" />
                    <FlexButton:FlexButton Margin="2" Height="60" Command="{Binding DisplayCustomerAccountsCommand }"
                         Content="{Binding DisplayCustomerAccountsCommand.Caption}" />
                </StackPanel>
            </Grid>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <StackPanel Margin="10">
                    <TextBlock Foreground="Gray" FontWeight="Bold" Text="{Binding TransactionDescription}" />
                    <Grid Visibility="{Binding IsCustomerDetailsVisible,Converter={StaticResource VisibilityConverter}}">
                        <Grid.Resources>
                            <Style TargetType="TextBlock">
                                <Setter Property="Margin" Value="0,5,5,5" />
                            </Style>
                        </Grid.Resources>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto" />
                            <ColumnDefinition Width="auto" />
                            <ColumnDefinition Width="auto" />
                            <ColumnDefinition Width="auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>
                        <TextBlock FontWeight="Bold" Grid.Row="0" Grid.Column="0" Text="{LocText AccountName,Suffix=':'}">
                        </TextBlock>
                        <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding SelectedCustomer.Name}" />
                        <TextBlock FontWeight="Bold" Grid.Row="0" Grid.Column="2" Text="{LocText PhoneNumber,Suffix=':'}">
                        </TextBlock>
                        <TextBlock Grid.Row="0" Grid.Column="3" Text="{Binding SelectedCustomer.PhoneNumberText}" />
                        <TextBlock FontWeight="Bold" Grid.Row="1" Grid.Column="0" Text="{LocText Address,Suffix=':'}">
                        </TextBlock>
                        <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding SelectedCustomer.Address}" />
                        <TextBlock FontWeight="Bold" Grid.Row="1" Grid.Column="2" Text="{LocText Note,Suffix=':'}">
                        </TextBlock>
                        <TextBlock Grid.Row="1" Grid.Column="3" Text="{Binding SelectedCustomer.Note}" />
                    </Grid>
                    <TextBlock Text="{LocText Description}" />
                    <TextBox Text="{Binding Description}" Name="DescriptionEditor" />
                    <TextBlock Text="{LocText Amount}" />
                    <Common:FilteredTextBox Name="AmountEditor" Type="Number" HorizontalAlignment="Left"
                         MinWidth="100" Text="{Binding Amount,StringFormat='{}{0:#,##.##}',UpdateSourceTrigger=PropertyChanged}"
                         Loaded="FilteredTextBox_Loaded" />

                    <StackPanel Orientation="Horizontal" Height="70">
                        <FlexButton:FlexButton MinWidth="200" Margin="0,5,5,5" Command="{Binding ApplyCashTransactionCommand}"
                             Content="{Binding ApplyCashTransactionCommand.Caption}" Visibility="{Binding IsPaymentButtonsVisible,Converter={StaticResource VisibilityConverter}}" />
                        <FlexButton:FlexButton MinWidth="100" Margin="5" Command="{Binding ApplyCreditCardTransactionCommand}"
                             Content="{Binding ApplyCreditCardTransactionCommand.Caption}" Visibility="{Binding IsPaymentButtonsVisible,Converter={StaticResource VisibilityConverter}}"/>
                        <FlexButton:FlexButton MinWidth="100" Margin="5" Command="{Binding ApplyTicketTransactionCommand}"
                             Content="{Binding ApplyTicketTransactionCommand.Caption}" Visibility="{Binding IsPaymentButtonsVisible,Converter={StaticResource VisibilityConverter}}"/>
                        <FlexButton:FlexButton HorizontalAlignment="Left" MinWidth="100" Margin="0,5,5,5" Command="{Binding ApplyTransactionCommand}"
                             Content="{Binding ApplyTransactionCommand.Caption}" Visibility="{Binding IsTransactionButtonVisible,Converter={StaticResource VisibilityConverter}}"/>
                        <FlexButton:FlexButton MinWidth="100" Margin="10,5" Command="{Binding CancelTransactionCommand}"
                             Content="{Binding CancelTransactionCommand.Caption}" />
                    </StackPanel>
                </StackPanel>
                <Viewbox Grid.Row="1" VerticalAlignment="Bottom">
                    <VirtualKeyboard:KeyboardView>
                    </VirtualKeyboard:KeyboardView>
                </Viewbox>
            </Grid>
        </TabControl>
    </Grid>
</UserControl>